define(['plugins/router', 'knockout'], function(router, ko) {
    var childRouter = router.createChildRouter()
        .makeRelative({
            moduleId:'ko',
            fromParent:true
        }).map([
            { route: ['', 'helloWorld'],    moduleId: 'helloWorld/helloWorld',  title: '你好世界',           type: 'intro',      nav: true },
            { route: 'clickCounter',        moduleId: 'clickCounter/index',     title: '点击计数器',         type: 'intro',      nav: true },
            { route: 'simpleList',          moduleId: 'simpleList/index',       title: '简单列表',           type: 'intro',      nav: true },
            { route: 'betterList',          moduleId: 'betterList/index',       title: '简单列表v2',           type: 'intro',      nav: true },
            { route: 'controlTypes',        moduleId: 'controlTypes/index',     title: '控件类型',         type: 'intro',      nav: true },
            { route: 'collections',         moduleId: 'collections/index',      title: '集合',            type: 'intro' ,     nav: true },
            { route: 'pagedGrid',           moduleId: 'pagedGrid/index',        title: '分页表格',            type: 'intro',      nav: true },
            { route: 'animatedTrans',       moduleId: 'animatedTrans/index',    title: '动画转换',   type: 'intro',      nav: true },
            { route: 'contactsEditor',      moduleId: 'contactsEditor/index',   title: '联系人编辑器',       type: 'detailed',   nav: true },
            { route: 'gridEditor',          moduleId: 'gridEditor/index',       title: '网格编辑器',           type: 'detailed',   nav: true },
            { route: 'shoppingCart',        moduleId: 'shoppingCart/index',     title: '购物车',         type: 'detailed',   nav: true }
        ]).buildNavigationModel();

    return {
        router: childRouter,
        introSamples: ko.computed(function() {
            return ko.utils.arrayFilter(childRouter.navigationModel(), function(route) {
                return route.type == 'intro';
            });
        }),
        detailedSamples: ko.computed(function() {
            return ko.utils.arrayFilter(childRouter.navigationModel(), function(route) {
                return route.type == 'detailed';
            });
        })
    };
});